package com.beinhospital_sw21_h2_05.beinhospitalsw21h205.mapper;

import com.beinhospital_sw21_h2_05.beinhospitalsw21h205.entity.Admission;
import com.beinhospital_sw21_h2_05.beinhospitalsw21h205.entity.MedicalOrder;
import com.beinhospital_sw21_h2_05.beinhospitalsw21h205.entity.Patient;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * MyBatis Mapper接口，用于与数据库表MedicalOrder进行交互
 */
@Mapper
public interface MedicalOrderMapper {

    /**
     * 获取Admission数据
     * @param bed_number 床位号
     * @return Admission列表
     */
    List<Admission> list(String bed_number);

    /**
     * 添加医生嘱咐
     * @param medicalOrder 医嘱对象
     */
    @Insert("INSERT INTO MedicalOrder (StartDate, EndDate, PatientID, Diagnosis, MedicineID, Quantity, Status, MedicineName) " +
            "values(#{StartDate},#{EndDate},#{PatientID},#{Diagnosis},#{MedicineID},#{Quantity},#{Status},#{MedicineName})")
    void insert(MedicalOrder medicalOrder);

    /**
     * 根据药品名查询药品ID
     * @param medicineName 药品名
     * @return 药品ID
     */
    @Select("select MedicineID from Medicine where MedicineName = #{medicineName}")
    int getID(String medicineName);
}
